//
//  main.cpp
//  recursion
//
//  Created by huge on 2021/6/25.
//  Copyright © 2021 huge. All rights reserved.
//

#include <iostream>
#include <vector>

int recurion(int max,int min){
    
    if (max == min) {
        return min;
    }
    return (max * recurion(max-1, min));
}

class fibonacci{

public:
    std::vector<int>fiboArray;


public:
    std::vector<int> getFibonacciArray(int n){
        std::vector<int> fiboArray;
        for (int i =1; i<=n; i++) {
            int fibo = doFibonacci(i);
            fiboArray.push_back(fibo);
        }
        return fiboArray;
    }
    
     int doFibonacci(int n) {
        if (n == 1) {     // 递归终止条件
            return 1;       // 简单情景
        }else if ( n == 2){
            return 1;       // 简单情景

        }
        return doFibonacci(n - 1) + doFibonacci(n - 2); // 相同重复逻辑，缩小问题的规模
    }
};



int main(int argc, const char * argv[]) {
    // insert code here...
    
//    int value = recurion(5, 1);
//    std::cout <<"value: "<<value<<std::endl;
    
    fibonacci fib;
    fib.doFibonacci(3);
    std::cout << "n :" <<  fib.doFibonacci(5)<<std::endl;
    
    fib.fiboArray = fib.getFibonacciArray(5);
    
    for (int i =0; i<fib.fiboArray.size(); i++) {
        std::cout <<"value: "<<fib.fiboArray[i]<<std::endl;

    }

    
    std::cout << "Hello, World!\n";
    return 0;
}
